<template>
  <div>
    <el-dialog width='654px' :visible.sync="detailsVisible" @close="hide" class="dialog_details">
      <div slot="title" class="dialog-title">{{detailsType==1?'职位详情':'职位审核'}}</div>
      <el-card class="el-card-border">
        <el-form :label-position="labelPosition" label-width="100px">
          <el-form-item label='账号：' v-if="details&&details.user_info">
            <span>{{details.user_info.mobile}}</span>
          </el-form-item>
          <el-form-item label='公司名称：' v-if="details.company_info">
            <span>{{details.company_info.name}}</span>
          </el-form-item>
          <el-form-item label='职位类型：'>
            <span>{{details.diy_post_type || getAttrValue(details.value_list,'POST_TYPE')}}</span>
          </el-form-item>
          <el-form-item label='工作类型：' v-if="getAttrValue(details.value_list,'WORK_TYPE')">
            <span>{{getAttrValue(details.value_list,'WORK_TYPE')}}</span>
          </el-form-item>
          <el-form-item label='薪资范围：'>
            <span>{{getSalary(details)}}</span>
          </el-form-item>
          <el-form-item label='福利待遇：'>
            <span class='trea_item' v-for="(item,index) in getAttr(details.value_list,'TREA')" :key="index+'trea'">{{item.value_name}}</span>
            <span class='trea_item' v-for="(item,index) in details.treatment?details.treatment.split(','):[]" :key='index'>{{item}}</span>
          </el-form-item>
          <el-form-item label='工作城市：'>
            <span class='trea_item'>{{details.province_name}}{{details.city_name}}{{details.district_name}}{{details.address}}</span>
          </el-form-item>
          <el-form-item label='年龄范围：'>
            <span class='trea_item'>{{getAttrValue(details.value_list,'AGE_REQUIRE')}}</span>
          </el-form-item>
          <el-form-item label='经验要求：'>
            <span class='trea_item'>{{getAttrValue(details.value_list,'EXP_REQUIRE')}}</span>
          </el-form-item>
          <el-form-item label='岗位职责：'>
            <span class='trea_item'>{{details.duty}}</span>
          </el-form-item>
          <el-form-item label='联系人：'>
            <span class='trea_item'>{{details.contacts}}</span>
          </el-form-item>
          <el-form-item label='联系电话：'>
            <span class='trea_item'>{{details.contacts_mobile}}</span>
          </el-form-item>
          <el-divider>补充信息</el-divider>
          <template v-if="details.company_info">
            <el-form-item label='公司LOGO：'>
              <img :src="baseUrl+'/'+details.company_info.company_logo" alt="" class="img">
            </el-form-item>
            <el-form-item label='公司介绍：'>
              <span>{{details.company_info.desc}}</span>
            </el-form-item>
            <el-form-item label='工作环境：' v-if="details.company_info.company_img">
              <img :src="baseUrl+'/'+item" v-for="(item,index) in details.company_info.company_img.split(',')" :key="index" class="img">
            </el-form-item>
          </template>
          <template v-if="detailsType==2">
            <el-form-item label='审核状态：'>
              <el-select v-model="detailsFormFieldsData.status">
                <el-option
                  v-for="item in statusList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label='驳回原因：' v-if="detailsFormFieldsData.status==2">
              <el-input type="textarea" v-model="detailsFormFieldsData.remake" style="width: 92%"></el-input>
            </el-form-item>
          </template>
          <template v-else>
            <el-form-item label='审核状态：'>
              <span>{{details.status==0?'审核中':details.status==1?'已通过':'已拒绝'}}</span>
            </el-form-item>
            <el-form-item label='驳回原因：' v-if="detailsFormFieldsData.status==2">
              <span>{{details.remake}}</span>
            </el-form-item>
          </template>
        </el-form>
      </el-card>
      <div slot="footer" class="dialog-footer" v-if="detailsType==2">
        <el-button @click="hide" size='medium'>取 消</el-button>
        <el-button type="primary" @click="examineSubmit" size='medium'>确 定</el-button>
      </div>
      <div slot="footer" class="dialog-footer" v-else>
        <el-button type="primary" @click="hide" size='medium'>关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import formOperate from '@/layout/mixin/formOperate'
export default {
  name: 'Index',
  mixins: [formOperate],
  data() {
    return {
      url:'/profession/admin/post/',
      details:'',//详情数据
      detailsVisible:false,
      detailsFormFieldsData:{
        id:'',
        status:'0',
        remake:''
      },
      detailsType:'',// 详情弹框是否审核，1 详情 2 审核
      statusList:[
        {label:'待审核',value:'0'},
        {label:'审核通过',value:'1'},
        {label:'审核驳回',value:'2'}
      ]
    }
  },
  methods: {
    getList(){
      console.log(12313)
    },
    // 查看详情
    show(item,type) {
      this.detailsType = type
      this.$http.get(this.url+item.id).then(response => {
        this.details = response.data.data || response.data
      })
      this.detailsFormFieldsData.id = item.id
      this.detailsVisible  = true
    },
    // 隐藏职位详情dialog
    hide() {
      this.detailsVisible = false
    },
    // 审核提交
    examineSubmit() {
      if (this.detailsFormFieldsData.status == 0) return
      this.$emit('postUpdate',this.detailsFormFieldsData,'status')
    }
  }
}
</script>
<style lang="scss" scoped>
  .el-form-item--small.el-form-item{
    margin-bottom:10px!important;
  }
  .img{
    width: 150px;
    margin:0 10px 10px 0;
  }
  .trea_item{
    margin-right: 10px;
  }
</style>